package com.ctgu.examonline.controller;

import com.ctgu.examonline.entity.Manager;
import com.ctgu.examonline.service.ManagerService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager")
public class ManagerController {

    private final ManagerService managerService;

    public ManagerController(ManagerService managerService) {
        this.managerService = managerService;
    }

    @CrossOrigin
    @RequestMapping("/login")
    public String managerLogin(@RequestBody Manager manager) {
        System.out.println("Manager : " + manager);
        String str = "error";
        int count = managerService.login(manager.getMana_no(), manager.getMana_pwd());
        if (count == 1) {
            str = "ok";
        }
        return str;
    }
}
